
import { render, createVNode, } from 'vue'
import preview from '@/components/FilePreviewModal/index.vue'
 
interface DialogOptions {
    type: string;
    src: string;
    visible: boolean;
}
 
export default {
    open: (options: DialogOptions) => {
      const wrapper = document.createElement('div')
      wrapper.id = 'preview-box'; 
      wrapper.style.position='fixed'
      wrapper.style.zIndex='9999'
      let vnode = createVNode(preview); // 创建一个vnode
      const close = () => {
        // 关闭弹窗移除标签
        document.body.removeChild(document.getElementById('preview-box') as HTMLDivElement);
      }
      const dialogProps = reactive({
          type: options.type,
          src: options.src,
          onClose: close
      });
      vnode = createVNode(preview, dialogProps);
      render(vnode, wrapper); // 渲染组件
      document.body.appendChild(wrapper); // 添加到body
    }
  }
